import {DataStore} from "./DataStore.js";
import {URL} from "./ConstUrl.js";

export class RequestServer {
    constructor(game_id, game_auth_code) {
        this.headers = {
            'content-type': 'application/x-www-form-urlencoded',
            'accept': 'application/json',
            'Game-ID': game_id,
            'Game-Auth-Code': game_auth_code
        };
        this.dataStore = DataStore.getInstance();
    }

    requestServer(successCallback, failsCallback, path, params, headers = this.headers) {
        wx.request({
            url: `${URL}${path}`,
            method: 'POST',
            data: params,
            header: headers,
            success: (res) => {
                successCallback(res);
            },
            fail:
                (res) => {
                    failsCallback(res);
                }
        });
    }

    request(res) {
        console.log(res);
    }
}